{include file='public/head'}
<body>
<div class="x-body">
    <form class="layui-form" id='mainForm' method="post" action="edit.html">

        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red">*</span>标题</label>
            <div class="layui-input-block">
                <input type="text" id="title" name="title" value="{$info.title}" autocomplete="off" class="layui-input" lay-verify="required">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red">*</span>内容</label>
            <div class="layui-input-block">
                <textarea id="content" name="content" style="display: none;">{$info.content}</textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red">*</span>排序</label>
            <div class="layui-input-block">
                <input type="number" id="odx" name="odx" value="{$info.odx}" autocomplete="off" class="layui-input"
                       lay-verify="required" placeholder="从小到大" min="0">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-block">
                <input type="radio" name="type" value="1" title="启用" checked>
                <input type="radio" name="type" value="2" title="禁用">
            </div>
        </div>

        <div class="layui-form-item">
            <div>
                <input type="hidden" id="id" name="id" value="{$info.id}">
                <button style="width: 100%" class="layui-btn" lay-submit="" lay-filter="toSubmit">提交保存</button>
            </div>
        </div>

    </form>
</div>
</body>
{include file='public/foot'}
<script type="text/javascript">

    $(document).ready(function () {
        var layer = layui.layer;
        var layedit = layui.layedit;
        layedit.build('content', {
            tool: [
                'strong' //加粗
                ,'italic' //斜体
                ,'underline' //下划线
                ,'del' //删除线
                ,'|' //分割线
                ,'left' //左对齐
                ,'center' //居中对齐
                ,'right' //右对齐
                ,'link' //超链接
                ,'unlink' //清除链接
            ]
        }); //建立编辑器

        var options = {
            type: 'post',           //post提交
            dataType: "json",        //json格式
            data: {},    //如果需要提交附加参数，视情况添加
            clearForm: false,        //成功提交后，清除所有表单元素的值
            resetForm: false,        //成功提交后，重置所有表单元素的值
            cache: false,
            async: false,          //同步返回
            success: function (data) {
                if (data.code == 0) {
                    layer.msg(data.msg);
                } else {
                    layer.msg(data.msg, {icon: 1, time: 500}, function () {
                        $("#reset").click();
                        x_admin_close();
                        parent.location.reload();
                    });
                }
                //服务器端返回处理逻辑
            },
            error: function (XmlHttpRequest, textStatus, errorThrown) {
                layer.msg('操作失败:服务器处理失败');
            }
        };

        // bind form using 'ajaxForm'
        $('#mainForm').ajaxForm(options).submit(function (data) {
        });
    });
</script>
</html>
